Skip to content

Event Types Reference

Complete catalog of all 50+ event types organized by category

This is a comprehensive reference of all events emitted by HPD-Agent. For practical usage patterns, see Consuming Events.

Quick Navigation


Turn Lifecycle Events

** CRITICAL**: MessageTurnFinishedEvent is when the agent is DONE. Use this to stop loading spinners!

Event TypeC# ClassDescriptionCommon Use
MESSAGE_TURN_STARTEDMessageTurnStartedEventUser message processing beginsStart loading indicator
MESSAGE_TURN_FINISHEDMessageTurnFinishedEventAgent finished ← Use this!Stop loading, enable input
MESSAGE_TURN_ERRORMessageTurnErrorEventUnrecoverable errorShow error message
AGENT_TURN_STARTEDAgentTurnStartedEventInternal LLM call beginsDebug/logging only
AGENT_TURN_FINISHEDAgentTurnFinishedEventInternal LLM call endsDebug/logging only
STATE_SNAPSHOTStateSnapshotEventCurrent iteration stateShow iteration count

MessageTurnStartedEvent

csharp
public record MessageTurnStartedEvent(
    string MessageTurnId,        // Unique ID for this message turn
    string ConversationId,        // Conversation/thread ID
    string AgentName,             // Name of the agent
    DateTimeOffset Timestamp      // When processing started
) : AgentEvent;

MessageTurnFinishedEvent

csharp
public record MessageTurnFinishedEvent(
    string MessageTurnId,        // Matches MessageTurnStartedEvent
    string ConversationId,
    string AgentName,
    TimeSpan Duration,           // How long the turn took
    DateTimeOffset Timestamp
) : AgentEvent;

MessageTurnErrorEvent

csharp
public record MessageTurnErrorEvent(
    string Message,              // Error message to show user
    Exception? Exception = null  // Full exception details
) : AgentEvent, IErrorEvent;

Content Events

The agent's text response streaming:

Event TypeC# ClassDescriptionCommon Use
TEXT_MESSAGE_STARTTextMessageStartEventAssistant message beginsShow message boundary
TEXT_DELTATextDeltaEventStreaming text chunkAppend to UI
TEXT_MESSAGE_ENDTextMessageEndEventAssistant message completeMark message complete

TextDeltaEvent

csharp
public record TextDeltaEvent(
    string Text,      // The text chunk to display
    string MessageId  // Message identifier
) : AgentEvent;

Example:

csharp
case TextDeltaEvent delta:
    // Accumulate and display
    messageBuilder.Append(delta.Text);
    Console.Write(delta.Text);
    break;

Reasoning Events

Extended thinking (for reasoning-capable models like Claude, o1, DeepSeek-R1):

Event TypeC# ClassDescriptionCommon Use
REASONING_MESSAGE_STARTReasoningMessageStartEventReasoning beginsShow "Thinking..." indicator
REASONING_DELTAReasoningDeltaEventStreaming reasoning contentDisplay internal thoughts
REASONING_MESSAGE_ENDReasoningMessageEndEventReasoning completeHide thinking indicator

ReasoningDeltaEvent

csharp
public record ReasoningDeltaEvent(
    string Text,      // Reasoning content chunk
    string MessageId
) : AgentEvent;

Example:

csharp
case ReasoningDeltaEvent reasoning:
    Console.Write($"[Thinking: {reasoning.Text}]");
    break;

Tool Events

When the agent calls functions:

Event TypeC# ClassDescriptionCommon Use
TOOL_CALL_STARTToolCallStartEventTool invocation beginsShow "Calling tool..."
TOOL_CALL_ARGSToolCallArgsEventTool arguments availableDisplay arguments
TOOL_CALL_ENDToolCallEndEventTool call completeMark tool finished
TOOL_CALL_RESULTToolCallResultEventTool execution resultShow result/error

ToolCallStartEvent

csharp
public record ToolCallStartEvent(
    string CallId,     // Unique call identifier
    string Name,       // Tool/function name
    string MessageId
) : AgentEvent;

ToolCallResultEvent

csharp
public record ToolCallResultEvent(
    string CallId,
    string Result      // JSON result or error message
) : AgentEvent;

Example:

csharp
case ToolCallStartEvent toolStart:
    Console.WriteLine($"\n[Calling: {toolStart.Name}]");
    break;

case ToolCallResultEvent toolResult:
    Console.WriteLine($"[Result: {toolResult.Result}]");
    break;

Bidirectional Events

** CRITICAL**: These events require calling agent.SendMiddlewareResponse() or the agent will hang!

Permission Events

Request/response pattern for user approval:

Request EventResponse EventDescription
PermissionRequestEventPermissionResponseEventAsk user to approve tool execution
ContinuationRequestEventContinuationResponseEventAsk to continue beyond max iterations

PermissionRequestEvent

csharp
public record PermissionRequestEvent(
    string PermissionId,                   // Unique ID for this request
    string SourceName,                      // Middleware that requested
    string FunctionName,                    // Tool being called
    string? Description,                    // Human-readable description
    string CallId,                          // Tool call ID
    IDictionary<string, object?>? Arguments // Tool arguments
) : AgentEvent, IPermissionEvent;

PermissionResponseEvent

csharp
public record PermissionResponseEvent(
    string PermissionId,                    // Matches request
    string SourceName,
    bool Approved,                          // User's decision
    string? Reason = null,                  // Optional reason
    PermissionChoice Choice = PermissionChoice.Ask
) : AgentEvent, IPermissionEvent;

Example:

csharp
case PermissionRequestEvent permission:
    var approved = await PromptUserAsync($"Allow {permission.FunctionName}?");

    // MUST send response or agent hangs!
    agent.SendMiddlewareResponse(permission.PermissionId,
        new PermissionResponseEvent
        {
            PermissionId = permission.PermissionId,
            SourceName = permission.SourceName,
            Approved = approved
        });
    break;

Clarification Events

Request additional information from the user:

Request EventResponse EventDescription
ClarificationRequestEventClarificationResponseEventAsk user for more information

ClarificationRequestEvent

csharp
public record ClarificationRequestEvent(
    string RequestId,
    string SourceName,
    string Question,           // Question to ask user
    string? AgentName = null,  // Name of the agent asking
    string[]? Options = null   // Optional list of choices to present
) : AgentEvent, IClarificationEvent;

ClarificationResponseEvent

csharp
public record ClarificationResponseEvent(
    string RequestId,          // Matches request
    string SourceName,
    string Question,           // The original question being answered
    string Answer              // User's answer
) : AgentEvent, IClarificationEvent;

Notification Events

One-way notifications (no response needed):

Event TypeC# ClassDescription
PERMISSION_APPROVEDPermissionApprovedEventEmitted after permission approved
PERMISSION_DENIEDPermissionDeniedEventEmitted after permission denied

Client Tools Events

For tools that execute in the browser/client (file pickers, geolocation, etc.):

Event TypeDescription
ClientToolInvokeRequestEventAgent requests client-side tool execution
ClientToolInvokeResponseEventClient returns tool result
ClientToolkitsRegisteredEventClient registered its tool groups
CollapsedToolsVisibleEventCollapsed tools are now visible
ContainerExpandedEventContainer was expanded

Streaming Control Events

InterruptionRequestEvent

Emitted to request interruption of active streams or operations. Used for user-initiated stops and system-level cancellations.

csharp
public record InterruptionRequestEvent(
    string? StreamId,          // Stream to interrupt (null = all streams)
    string Reason,             // Human-readable reason
    InterruptionSource Source  // Who initiated: User, System, Parent, Middleware
) : AgentEvent;

Structured Output Events

Events emitted during RunStructuredAsync<T>():

Event TypeC# ClassDescription
STRUCTURED_RESULTStructuredResultEvent<T>Parsed result (may be partial)

StructuredResultEvent<T>

csharp
public sealed record StructuredResultEvent<T>(
    T Value,         // Parsed value (partial or complete)
    bool IsPartial,  // True if streaming still in progress
    string RawJson   // Raw JSON that was parsed
) : AgentEvent where T : class;

Example:

csharp
case StructuredResultEvent<WeatherReport> result:
    if (result.IsPartial)
        UpdatePreviewUI(result.Value);  // Show partial data as it streams
    else
        ShowFinalResult(result.Value);  // Final complete object
    break;

Observability Events

** ALWAYS FILTER THESE OUT** in user-facing code!

These implement IObservabilityEvent and are for internal diagnostics:

csharp
// FIRST LINE of your event handler:
if (evt is IObservabilityEvent) continue;
Event TypeC# ClassDescription
MIDDLEWARE_PROGRESSMiddlewareProgressEventMiddleware processing update
MIDDLEWARE_ERRORMiddlewareErrorEventMiddleware failure
MIDDLEWARE_PIPELINE_STARTMiddlewarePipelineStartEventPipeline processing begins
MIDDLEWARE_PIPELINE_ENDMiddlewarePipelineEndEventPipeline processing complete
PERMISSION_CHECKPermissionCheckEventPermission check timing
ITERATION_STARTIterationStartEventAgent iteration begins
CIRCUIT_BREAKER_TRIGGEREDCircuitBreakerTriggeredEventSafety limit reached
HISTORY_REDUCTION_CACHEHistoryReductionCacheEventHistory reduction metrics
CHECKPOINTCheckpointEventState checkpoint saved
BACKGROUND_OPERATION_STARTEDBackgroundOperationStartedEventAsync operation started
BACKGROUND_OPERATION_STATUSBackgroundOperationStatusEventAsync operation status
INTERNAL_PARALLEL_TOOL_EXECUTIONInternalParallelToolExecutionEventParallel tool execution
INTERNAL_RETRYInternalRetryEventInternal retry attempt
MODEL_CALL_RETRYModelCallRetryEventLLM streaming retry — clear partial UI text when received
FUNCTION_RETRYFunctionRetryEventFunction retry attempt
DELTA_SENDING_ACTIVATEDDeltaSendingActivatedEventDelta sending enabled
PLAN_MODE_ACTIVATEDPlanModeActivatedEventPlan mode activated
NESTED_AGENT_INVOKEDNestedAgentInvokedEventSubAgent spawned
DOCUMENT_PROCESSEDDocumentProcessedEventDocument processing metrics
INTERNAL_MESSAGE_PREPAREDInternalMessagePreparedEventMessage prepared
BIDIRECTIONAL_EVENT_PROCESSEDBidirectionalEventProcessedEventBidirectional event handled
AGENT_DECISIONAgentDecisionEventAgent decision points
AGENT_COMPLETIONAgentCompletionEventAgent completion details
ITERATION_MESSAGESIterationMessagesEventMessages for iteration
SCHEMA_CHANGEDSchemaChangedEventSchema changed
COLLAPSING_STATECollapsingStateEventCollapsing state update
EVENT_DROPPEDEventDroppedEventEvents dropped (interruption)

ModelCallRetryEvent (Notable)

Although tagged as IObservabilityEvent, this event has a critical UI implication: clear any partial response text when received — a fresh response stream is about to begin.

csharp
public record ModelCallRetryEvent(
    int Attempt,          // Current retry number (1-based)
    int MaxRetries,       // Maximum retries configured
    TimeSpan Delay,       // Wait time before retry
    Exception Exception,
    string ExceptionType,
    string ErrorMessage
) : AgentEvent, IObservabilityEvent, IErrorEvent;

Example:

csharp
// Enable observability events to receive this
case ModelCallRetryEvent retry:
    responseBuffer.Clear();  // Clear partial text — fresh content coming
    Console.WriteLine($"Retrying (attempt {retry.Attempt}/{retry.MaxRetries})...");
    break;

Supporting Types

Enums

EventPriority

csharp
public enum EventPriority
{
    Immediate = 0,  // User cancellation, emergency stops
    Control = 1,    // System control signals
    Normal = 2,     // Standard data flow (DEFAULT)
    Background = 3  // Metrics, telemetry
}

EventDirection

csharp
public enum EventDirection
{
    Downstream,  // Normal: input → processing → output
    Upstream     // Control: cancellation signals flowing back
}

InterruptionSource

csharp
public enum InterruptionSource
{
    User,       // User clicked stop, pressed Ctrl+C
    System,     // Timeout, circuit breaker
    Parent,     // Parent agent aborting child
    Middleware  // Permission denied, validation failed
}

PermissionChoice

csharp
public enum PermissionChoice
{
    Ask,        // Ask user each time
    Allow,      // Always allow
    Deny        // Always deny
}

Marker Interfaces

IBidirectionalEvent

csharp
public interface IBidirectionalEvent
{
    string SourceName { get; }
}

Events that support request/response patterns.

IPermissionEvent

csharp
public interface IPermissionEvent : IBidirectionalEvent
{
    string PermissionId { get; }
}

Permission-related events.

IClarificationEvent

csharp
public interface IClarificationEvent : IBidirectionalEvent
{
    string RequestId { get; }
    string Question { get; }
}

Clarification-related events.

IObservabilityEvent

csharp
public interface IObservabilityEvent { }

Marker for internal diagnostic events that should be filtered out.

IErrorEvent

csharp
public interface IErrorEvent
{
    string ErrorMessage { get; }
}

Events representing errors.

AgentEvent Base Class

All events inherit from AgentEvent:

csharp
public abstract record AgentEvent
{
    public AgentExecutionContext? ExecutionContext { get; init; }
    public EventPriority Priority { get; init; } = EventPriority.Normal;
    public long SequenceNumber { get; internal set; }
    public EventDirection Direction { get; init; } = EventDirection.Downstream;
    public string? StreamId { get; init; }
    public bool CanInterrupt { get; init; } = true;
}

AgentExecutionContext

For nested agent scenarios (see SubAgent Events):

csharp
public record AgentExecutionContext
{
    public required string AgentName { get; init; }
    public required string AgentId { get; init; }
    public string? ParentAgentId { get; init; }
    public IReadOnlyList<string> AgentChain { get; init; }
    public int Depth { get; init; }
    public bool IsSubAgent => Depth > 0;
}

See Also

Released under the MIT License.